package com.yima.baseproj.module.app.clazz;

import com.yima.baseproj.aop.log.Logging;
import com.yima.baseproj.module.config.utils.ResultUtil;
import com.yima.baseproj.module.config.utils.ResultVo;
import com.yima.baseproj.module.sys.clazz.ClassEntity;
import com.yima.baseproj.module.sys.clazz.ClassService;
import com.yima.baseproj.module.sys.student.model.StudentSelectModel;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RequestMapping("/api/app/class")
@RestController
public class AppClassController {

    @Autowired
    private ClassService classService;

//    @PreAuthorize("hasAuthority('app:class:findAllByList')")
//    @ApiOperation("查询班级列表")
//    @GetMapping("/findAllByList")
//    public ResultVo getClass(ClassEntity classEntity) {
//        List<Map> classList = classService.findAllByList(classEntity);
//        return ResultUtil.success(classList);
//    }

    @ApiOperation("根据幼儿园id 查询班级列表")
    @GetMapping("/findClassListByKgId/{kgId}")
    public ResultVo findClassListByKgId(@PathVariable int kgId) {
        List<ClassEntity> classList = classService.findAllByKgId(kgId);
        return ResultUtil.success(classList);
    }

    @ApiOperation("根据id查询班级信息")
    @GetMapping("/findById/{id}")
    public ClassEntity findById(@PathVariable int id){
        ClassEntity classEntity = classService.findById(id);
        return classEntity;
    }

    @ApiOperation("修改")
    @PostMapping("/edit")
    public void editcl(@RequestBody ClassEntity customAdmin) {
        classService.edit(customAdmin);
    }
}
